<?php

namespace CMS\User\Models;
/**
 * Trida entity pro tabulku zdroju. 
 *
 * @author David Dusek
 */
use Doctrine\ORM\Mapping as ORM;

/** 
 * @ORM\Entity(repositoryClass="\CMS\User\Models\ResourceRepository")
 * @ORM\Table(name="user_resource")
 */
class Resource extends \Nette\Object {
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     * @var int 
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=100)
     * @var string 
     */
    private $title;
    
    /**
     * @ORM\Column(type="string", length=100)
     * @var string 
     */
    private $module;
    
    /**
     * @ORM\Column(type="string", length=100)
     * @var string 
     */
    private $presenter;
    
    /**
     * @ORM\OneToMany(targetEntity="\CMS\User\Models\Operation", mappedBy="resource", cascade={"persist", "remove"})
     */
    private $operations;
    
    public function __construct()
    {
        $this->operations = new \Doctrine\Common\Collections\ArrayCollection();        
    }
    
    public function getId() {
        return $this->id;
    }
    
    public function setTitle($title) {
        $this->title = $title; 
    }

    public function getTitle() {
        return $this->title;
    }

    public function setModule($module) {
        $this->module = $module; 
    }

    public function getModule() {
        return $this->module;
    }

    public function setPresenter($presenter) {
        $this->presenter = $presenter; 
    }

    public function getPresenter() {
        return $this->presenter;
    }
    
    public function addOperation(Operation $operation) {
        $this->operations->add($operation);
        $operation->setResource($this);
    }
    
    public function removeOperation(Operation $operation) {
        $this->articles->removeElement($operation);
        $operation->setResource(NULL);
    }
    
    /**
     * Operace pridruzene ke zdroji.
     * @return \Doctrine\Common\Collections\ArrayCollection
     */
    public function getOperations() {
        return $this->operations;
    }
}
